package com.example.my.shop.mybatis.controller;

import com.example.my.shop.mybatis.TbUser;
import com.example.my.shop.mybatis.service.Imp.TbUserServiceImpl;
import com.example.my.shop.mybatis.service.TbUserService;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(value = "/getUsers")
public class GetUsersController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        TbUserService tbUserService = new TbUserServiceImpl();
        List<TbUser> userList = tbUserService.findAll();
        req.setAttribute("userList", userList);
        req.getRequestDispatcher("viewUsers.jsp").forward(req, resp);
    }
}
